<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改首页平台承诺')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-commitment-edit" th:object="${cmsPlatformCommitment}">
            <input name="id" th:field="*{id}" type="hidden">
            <!--<div class="form-group">-->
                <!--<label class="col-sm-3 control-label">图标：</label>-->
                <!--<div class="col-sm-8">-->
                    <!--<textarea name="icon" class="form-control">[[*{icon}]]</textarea>-->
                <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">图标</label>
                <input name="icon" th:value="*{icon}" type="hidden">
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input name="file" id="fileinput-demo-1" type="file" multiple>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">显示状态</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_show_hide')}">
                        <option value="">所有</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
        var prefix = ctx + "mall/commitment";
        $("#form-commitment-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-commitment-edit').serialize());
            }
        }

        /**
         * 图片上传
         */
        $("#fileinput-demo-1").fileinput({
            'theme': 'explorer-fas',
            'uploadUrl': ctx +'aliyun/upload',
            autoReplace:true,
            initialPreviewAsData: true,
            overwriteInitial:true,
            initialPreview:[$("input[name='icon']").val()],
            uploadExtraData:{ //额外参数，将不同的文件存放不同的目录下
                "baseDir":"advertise"
            }
        }).on("fileuploaded", function(event, data, previewId, index) {//上传成功回调
            $("input[name='icon']").val(data.response.url);
            console.log(data.response.url);
        });
    </script>
</body>
</html>